﻿
using System.Configuration;
using System.Web.Mvc;
using Tau.Service;
using Tau.ViewModels;

namespace Tau.Web.Controllers
{
    public class PageController : Controller
    {
        public ActionResult GetPage(int id)
        {
            var svc = new TauService();

            var page = svc.GetPage(id);

            ViewBag.Title = string.Format("{0}, presented by Vesuvius Press", page.PageTitle);

            if (ConfigurationManager.AppSettings["IsDevDeployment"] != null &&
                ConfigurationManager.AppSettings["IsDevDeployment"] == "true")
            {
                page.PageCode = page.PageCode.Replace("../Image", "http://www.vesuviuspress.com/dev/Image");
            }
            else
            {
                page.PageCode = page.PageCode.Replace("../Image", "/Image");
            }
            

            return View("GetPage", page);
        }

        public ActionResult PagesPublicMenu()
        {
            var svc = new TauService();

            var pages = svc.GetPublicPages();

            return PartialView("PagesPublicMenu", new PageList { Pages = pages });
        }
    }
}
